package org.deltaset.meta.internal;

import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Map;
import org.deltaset.meta.MetaField;
import org.deltaset.meta.internal.testdomain.OrderChild;
import static org.junit.Assert.*;

/**
 *
 * @author dmakariev
 */
public final class OrderParentHelper {

    private OrderParentHelper() {
    }

    public static void assertFormFields(final List<MetaField> formMetaFields) {

        assertEquals("formMetaFields.size ", 2, formMetaFields.size());

        {
            final MetaField metaField = formMetaFields.get(0);

            final String propertyLabelKey = metaField.getPropertyLabelKey();
            assertEquals("metaField getPropertyLabelKey() ", "children", propertyLabelKey);

            final String propertyName = metaField.getPropertyName();
            assertEquals("metaField getPropertyName() ", "children", propertyName);

            final String propertyType = metaField.getPropertyType();
            assertEquals("metaField getPropertyType() ", "collection", propertyType);

            final Class originalType = metaField.getOriginalType();
            assertEquals("metaField getOriginalType() ", List.class, originalType);

            final Class genericType = metaField.getGenericType();
            assertEquals("metaField getGenericType() ", OrderChild.class, genericType);

            final Annotation[] annotations = metaField.getOriginalAnnotations();
            assertEquals("metaField getOriginalAnnotations().length ", 0, annotations.length);

            final Map<String, String> params = metaField.getParams();
            assertEquals("metaField getParams().size() ", 0, params.size());
        }

        {
            final MetaField metaField = formMetaFields.get(1);

            final String propertyLabelKey = metaField.getPropertyLabelKey();
            assertEquals("metaField getPropertyLabelKey() ", "parentName", propertyLabelKey);

            final String propertyName = metaField.getPropertyName();
            assertEquals("metaField getPropertyName() ", "parentName", propertyName);

            final String propertyType = metaField.getPropertyType();
            assertEquals("metaField getPropertyType() ", "string", propertyType);

            final Class originalType = metaField.getOriginalType();
            assertEquals("metaField getOriginalType() ", String.class, originalType);

            final Class genericType = metaField.getGenericType();
            assertEquals("metaField getGenericType() ", null, genericType);

            final Annotation[] annotations = metaField.getOriginalAnnotations();
            assertEquals("metaField getOriginalAnnotations().length ", 0, annotations.length);         

            //"cols=30", "rows=5"
            final Map<String, String> params = metaField.getParams();
            assertEquals("metaField getParams().size() ", 0, params.size());

        }
       
    }
}
